package com.yricky.tsp;

import TSP.SolveSession;

public class SimpleThread extends Thread{
    private Runner runner;
    private ExceptionHandler exceptionHandler;
    public SimpleThread(Runner runner, ExceptionHandler exceptionHandler){
        this.runner=runner;
        this.exceptionHandler=exceptionHandler;
    }

    @Override
    public void run() {
        super.run();
        try {
            runner.run();
        }catch (Exception e){
            if(exceptionHandler!=null)
                exceptionHandler.handle(e);
        }
    }

    public interface Runner{
        public void run();
    }
    public interface ExceptionHandler{
        public void handle(Exception e);
    }

}
